home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
5_5.lha
/
5_5
/
5_5a2.c
< prev
next >
Wrap
Text File
|
1993-08-08
|
845b
|
36 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
tatic void get_token(istream &input)
char ch;
do { // skip whitespace
if (!input.get(ch))
{ curr_tok.type = END; return; }
} while (isspace(ch));
switch (ch)
{
case '*': case '/': case '+': case '-':
case '(': case ')':
curr_tok.type = ch;
f (debug) cout << "get_token() returns '" << chr(ch) << "'\n"; // DELETE
return;
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
case '8': case '9':
input.putback(ch);
input >> curr_tok.value;
curr_tok.type = NUMBER;
f (debug) cout << "get_token() returns NUMBER='" << curr_tok.value << "'\n"; // DELETE
return;
default:
error("bad token");
curr_tok.type = END;
return;
}